package com.imut.lagain.entity;

import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.LocalDateTime;

/**
 * 系统通知实体类
 */
@TableName("system_notification")
public class SystemNotification {
    private static final Logger log = LoggerFactory.getLogger(SystemNotification.class);

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    
    /**
     * 接收者ID
     */
    @NotNull(message = "接收者ID不能为空")
    @TableField("receiver_id")
    private Long receiverId;
    
    /**
     * 触发者ID（操作发起人）
     */
    @TableField("trigger_user_id")
    private Long triggerUserId;
    
    /**
     * 通知类型
     */
    @NotBlank(message = "通知类型不能为空")
    @Size(max = 50, message = "通知类型长度不能超过50个字符")
    @TableField("notification_type")
    private String notificationType;
    
    /**
     * 通知标题
     */
    @NotBlank(message = "通知标题不能为空")
    @Size(max = 200, message = "通知标题长度不能超过200个字符")
    @TableField("title")
    private String title;
    
    /**
     * 通知内容
     */
    @NotBlank(message = "通知内容不能为空")
    @Size(max = 1000, message = "通知内容长度不能超过1000个字符")
    @TableField("content")
    private String content;
    
    /**
     * 相关资源ID（如胶囊ID、消息ID等）
     */
    @TableField("resource_id")
    private Long resourceId;
    
    /**
     * 相关资源类型
     */
    @Size(max = 50, message = "资源类型长度不能超过50个字符")
    @TableField("resource_type")
    private String resourceType;
    
    /**
     * 是否已读
     */
    @TableField("is_read")
    private Boolean isRead = false;
    
    /**
     * 读取时间
     */
    @TableField("read_time")
    private LocalDateTime readTime;
    
    /**
     * 优先级（1-低，2-中，3-高）
     */
    @TableField("priority")
    private Integer priority = 2;
    
    /**
     * 扩展数据（JSON格式）
     */
    @TableField("extra_data")
    private String extraData;
    
    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    
    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    
    /**
     * 是否删除
     */
    @TableLogic
    @TableField("is_deleted")
    private Boolean isDeleted = false;

    // 通知类型常量
    public static final String TYPE_CAPSULE_CREATED = "CAPSULE_CREATED";           // 胶囊创建
    public static final String TYPE_CAPSULE_OPENED = "CAPSULE_OPENED";             // 胶囊打开
    public static final String TYPE_THIEF_SUCCESS = "THIEF_SUCCESS";               // 小偷偷取成功
    public static final String TYPE_THIEF_FAILED = "THIEF_FAILED";                 // 小偷偷取失败
    public static final String TYPE_PARTNER_BOUND = "PARTNER_BOUND";               // 伴侣绑定
    public static final String TYPE_MOOD_SHARED = "MOOD_SHARED";                   // 心情分享
    public static final String TYPE_MEMORY_CREATED = "MEMORY_CREATED";             // 回忆创建
    public static final String TYPE_LETTER_RECEIVED = "LETTER_RECEIVED";           // 收到信件
    public static final String TYPE_PERIOD_REMINDER = "PERIOD_REMINDER";           // 生理期提醒
    public static final String TYPE_SYSTEM_UPDATE = "SYSTEM_UPDATE";               // 系统更新
    
    // 资源类型常量
    public static final String RESOURCE_CAPSULE = "CAPSULE";
    public static final String RESOURCE_MESSAGE = "MESSAGE";
    public static final String RESOURCE_MOOD = "MOOD";
    public static final String RESOURCE_MEMORY = "MEMORY";
    public static final String RESOURCE_LETTER = "LETTER";
    public static final String RESOURCE_USER = "USER";

    // Getters and Setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getReceiverId() {
        return receiverId;
    }

    public void setReceiverId(Long receiverId) {
        this.receiverId = receiverId;
    }

    public Long getTriggerUserId() {
        return triggerUserId;
    }

    public void setTriggerUserId(Long triggerUserId) {
        this.triggerUserId = triggerUserId;
    }

    public String getNotificationType() {
        return notificationType;
    }

    public void setNotificationType(String notificationType) {
        this.notificationType = notificationType;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Long getResourceId() {
        return resourceId;
    }

    public void setResourceId(Long resourceId) {
        this.resourceId = resourceId;
    }

    public String getResourceType() {
        return resourceType;
    }

    public void setResourceType(String resourceType) {
        this.resourceType = resourceType;
    }

    public Boolean getIsRead() {
        return isRead;
    }

    public void setIsRead(Boolean isRead) {
        this.isRead = isRead;
    }

    public LocalDateTime getReadTime() {
        return readTime;
    }

    public void setReadTime(LocalDateTime readTime) {
        this.readTime = readTime;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public String getExtraData() {
        return extraData;
    }

    public void setExtraData(String extraData) {
        this.extraData = extraData;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Boolean getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Boolean isDeleted) {
        this.isDeleted = isDeleted;
    }
}